import $ from '../common';
Page({
  data: {
    // 相关功能的数组
    aboutArr: [{
        item: [{
          img: '../../image/icon_kebiao.png',
          tile: '我的课程',
          id: 1
        }, {
          img: '../../image/icon_dianming.png',

          tile: '上课点名',
          id: 2
        }, {
          img: '../../image/icon_dianping.png',

          tile: '学院点评',
          id: 3
        }, {
          img: '../../image/icon_zuoye.png',

          tile: '布置作业',
          id: 4
        }]
      },
      {
        item: [{
          img: '../../image/icon_banji.png',

          tile: '班级管理',
          id: 5
        }, {
          img: '../../image/icon_fankui.png',

          tile: '课程反馈',
          id: 6
        }, {
          img: '../../image/icon_qiandao.png',

          tile: '到岗签到',
          id: 7
        }, {}]
      }
    ],
    // 代办的数组
    readydo: [{
        classstate: 1,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 1
      }, {
        classstate: 2,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 2
      }, {
        classstate: 3,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 3
      }, {
        classstate: 3,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 1
      },
      {
        classstate: 1,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 1
      }, {
        classstate: 2,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 2
      }, {
        classstate: 3,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 3
      }, {
        classstate: 3,
        time: '今日(03-07) 08:00',
        introduce: '您的《创意手工入门班》即将开课，请尽快 前往上课，记得对学员进行点名签到',
        review: 1
      }
    ],
    titleHeight: $.gData().titleHeight,
    statuHeight: $.gData().statuHeight,
  },
  openabout(e) {
    const {
      currentTarget: {
        dataset: {
          id
        }
      }
    } = e;
    switch (id) {
      case 1:
        this.goschedule()
        break;
      case 2:
        this.goschedule()
        break;
      case 3:
        this.goreview()
        break;
      case 4:
        this.gohomework()
        break;
      case 5:
        this.gomanagement()
        break;
      case 6:
        this.gofeedback()
        break;
      case 7:
        this.gosignin()
        break;
    }
  },
  // 分享
  onShareAppMessage(res) {
    return {
      title: '移动办公，老师更轻松！',
      path: '/pages/index/index',
      imageUrl: 'https://sxzimgs.oss-cn-shanghai.aliyuncs.com/yingxiao/page/b827c6da-ac0c-11ec-a9c2-00163e04cc20.png'
    }
  },
  //获取用户账号
  getuserinfo() {
    $.get("/teacher/detail", {}, (res) => {
      wx.setStorageSync('uuid', res.teacher.uuid)
      wx.setStorageSync('teacher_uuid', res.teacher.teacher_uuid)
      wx.setStorageSync('campus_uuid', res.teacher.campus_uuid)
      this.setData({
        teachername: res.teacher.name,
        teaavatar: res.teacher.avatar
      })
    })
  },
  //获取用户课程
  gethomework() {
    $.get("/teacher/lesson/events", {}, (res) => {
      this.setData({
        today_lessons: res.today_lessons,
        waiting_review_lessons: res.waiting_review_lessons,
        sign_lessons: res.sign_lessons,
      })
    })
  },
  //代办中点名的点击事件
  handleCalroll(e) {
    const {
      lesson_uuid
    } = e.currentTarget.dataset
    $.navigateTo(`/Signin/Callroll?lesson_uuid=${lesson_uuid}`)
  },
  //代办中点名的点评事件
  handlerreview() {
    this.goreview()
  },
  //代办中签到的点击事件
  handleSign(e) {
    const {
      lesson_uuid
    } = e.currentTarget.dataset
    $.navigateTo(`/Signin/Signin?lesson_uuid=${lesson_uuid}`)
  },
  //去往课程
  goschedule() {
    $.navigateTo(`/schedule/schedule`)
  },
  //去往点评
  goreview() {
    $.navigateTo(`/classaboutPart/review`)
  },
  // 去往作业
  gohomework() {
    $.navigateTo(`/classaboutPart/homework`)
  },
  //去往管理
  gomanagement() {
    $.navigateTo(`/classaboutPart/management`)
  },
  // 去往反馈
  gofeedback() {
    $.navigateTo(`/classaboutPart/feedback`)
  },
  //去往签到
  gosignin() {
    $.navigateTo(`/schedule/signinsche`)
  },
  onLoad(e) {
    wx.removeStorageSync('$alreadyLoginWindow')

  },
  onShow() {
    this.gethomework()
    this.getuserinfo()
  }
})